from faker import Faker
from rich.console import Console
from rich.columns import Columns
from rich.panel import Panel

fake = Faker('zh_CN')  # Use Chinese localisation


def generate_user():
    """Generate a fake user profile."""
    return {
        "name": {
            "first": fake.first_name(),
            "last": fake.last_name(),
        },
        "location": {
            "country": fake.country(),
        }
    }


def get_content(user):
    """Extract text from user dict."""
    country = user["location"]["country"]
    name = f"{user['name']['first']} {user['name']['last']}"
    return f"[b]{name}[/b]\n[yellow] {country}"


console = Console()

# Generate 30 fake users
users = [generate_user() for _ in range(30)]

# Create rich panels for each user
user_render = [Panel(get_content(user), expand=True) for user in users]

# Print the user data in columns
console.print(Columns(user_render))
